<?php
namespace app\setting\controller;
use think\Request;
use app\common\controller\AdminBase;

class ApiAdminKey extends AdminBase
{
    public function keyInfo()
    {
    	$keyInfo = [];
        $settings = db('BaseKey')->select();
        foreach ($settings as $k => $v){
            $keyInfo[$v['key']] = $v['val'];
        }
        return jsonSuccess('',$keyInfo);
    }
    
    public function keySet()
    {
        $keyInfo = input('keyInfo/a');
        if ($keyInfo) {
        	foreach($keyInfo as $key => $val) {
        		if (db('BaseKey')->where('key',$key)->find()) {
			        db('BaseKey')->where('key',$key)->update(array('val' => $val));
		        } else {
			        db('BaseKey')->insert(array('key' => $key,'val' => $val));
		        }
        	}
        }
        return jsonSuccess('操作成功');
    }

}